﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace HikvisionDemo
{
    public partial class PreviewTestForm : Form
    {

        private Dictionary<string, int> userDict = new Dictionary<string, int>();
        private Dictionary<string, int> realPlayHandleDict = new Dictionary<string, int>();

        private string camera1 = "192.168.188.11";
        private string camera2 = "192.168.188.18";

        public PreviewTestForm()
        {
            InitializeComponent();

            // 初始化SDK
            InitSdkUtils.Init();

            userDict.Add(camera1, LoginUtils.Login(camera1, 8000, "admin", "xz123456"));
            userDict.Add(camera2, LoginUtils.Login(camera2, 8000, "admin", "xz123456"));
        }

        private void PreviewTestForm_Load(object sender, EventArgs e)
        {
            realPlayHandleDict.Add(camera1, PreviewUtils.RealPlay(userDict[camera1], pictureBox1.Handle));
            realPlayHandleDict.Add(camera2, PreviewUtils.RealPlay(userDict[camera2], pictureBox2.Handle));
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PreviewUtils.StopRealPlay(userDict[camera1]);
            PreviewUtils.StopRealPlay(userDict[camera2]);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            PreviewUtils.CapturePicture(userDict[camera1]);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            DeviceManageUtils.CheckOnline(userDict[camera1]);
            DeviceManageUtils.CheckOnline(userDict[camera2]);
        }
    }
}
